package com.hoshiicloud.saleorder.feign;

import com.hoshiicloud.common.rpc.Response;
import com.hoshiicloud.goods.entity.goods.GoodsSpecificationsValues;
import com.hoshiicloud.goods.entity.sku.ProductManage;
import com.hoshiicloud.goods.entity.spu.ExtSpu;
import com.hoshiicloud.goods.param.sku.ProductManageQueryParam;
import com.hoshiicloud.saleorder.dto.ExtSkuDTO;
import com.hoshiicloud.saleorder.dto.SkuDTO;
import com.hoshiicloud.saleorder.feign.hystrix.HystrixGoodsFeignFallback;
import com.hoshiicloud.saleorder.param.LockSkuStock;
import com.hoshiicloud.user.entity.customer.ExtSku;
import java.util.List;
import java.util.Map;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * @author zhangshuhu
 * @title: IdGeneratorService
 * @projectName hoshiicloud
 * @description: 主键服务
 * @since 2019-05-10
 */
@FeignClient(name = "hoshiicloud-goods", fallback = HystrixGoodsFeignFallback.class)
public interface GoodsService {

    /**
     * 查询sku库存信息
     *
     * @param ids
     * @return
     */
    @RequestMapping(value = "/goods/sku-info/getSkuStockByIds", method = {RequestMethod.POST})
    Response<Map<Long, SkuDTO>> getSkuStockByIds(@RequestBody List<Long> ids);

    /**
     * 查询总店SKU商品库存
     *
     * @param cartVoIdList cartVoIdList
     * @return Response
     */
    @PostMapping("/goods/sku-info/queryHeadOfficeSkuStockByIds")
    Response<Map<Long, SkuDTO>> queryHeadOfficeSkuStockByIds(@RequestBody List<Long> cartVoIdList);

    /**
     * 冻结商品sku库存
     *
     * @param lockSkuStocks
     * @return
     */
    @RequestMapping(value = "/goods/sku-info/lockSkuStock", method = {RequestMethod.POST})
    Response lockSkuStock(@RequestBody List<LockSkuStock> lockSkuStocks);

    /**
     * 解冻商品sku库存
     *
     * @param lockSkuStocks
     * @return
     */
    @RequestMapping(value = "/goods/sku-info/unLockSkuStock", method = {RequestMethod.POST})
    Response unLockSkuStock(@RequestBody List<LockSkuStock> lockSkuStocks);

    /**
     * 查询扩展sku
     *
     * @param id
     * @return
     */
    @RequestMapping(value = "/goods/ext-sku/{id}", method = {RequestMethod.GET})
    Response<ExtSkuDTO> getExtSku(@PathVariable("id") Long id);

    @RequestMapping(value = "/goods/sku-info/getExtSku", method = RequestMethod.POST)
    Response<SkuDTO> getSkuInfoExtSku(Long id);


    @GetMapping(value = "/goods/ext-sku/getByIds")
    Response<List<ExtSku>> getGoodsDetailByIds(List<Long> param);

    /**
     * 根据id获取扩展spu信息
     *
     * @param id 扩展spu主键
     * @return Response<ExtSpu>
     */
    @RequestMapping(value = "/goods/ext-spu/{id}", method = RequestMethod.GET)
    Response<ExtSpu> getExtSpuById(@PathVariable("id") Long id);

    /**
     * 根据扩展SPU主键查找同一类扩展SPU
     *
     * @param id 扩展SPU主键id
     * @return Response<List < ExtSpu>>
     */
    @RequestMapping(value = "/goods/ext-spu/getSimilarExtSpuById/{id}", method = RequestMethod.GET)
    Response<List<ExtSpu>> getSimilarExtSpuById(@PathVariable("id") Long id);

    /**
     * 通过specId得到商品规格名称列表
     *
     * @param specId specId
     * @return List
     */
    @GetMapping("/goods/goods-specifications-values/getSpecificationsValueToNameListBySpecId")
    Response<List<GoodsSpecificationsValues>> getSpecificationsValueToNameListBySpecId(
            @RequestParam("specId") Long specId);

    /**
     * 查询商品分配表
     * @param param 查询参数
     * @return Response<List<ProductManage>>
     */
    @RequestMapping(value = "/goods/product-manage/query/list", method = RequestMethod.POST)
    Response<List<ProductManage>> listProductManage(@RequestBody ProductManageQueryParam param);
}
